package com.lagou.server.filter;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @author caiwei
 * @date 2020-11-5 23:30
 */
@Slf4j
@Activate(group = {CommonConstants.PROVIDER,CommonConstants.CONSUMER})
public class TransportIPFilter implements Filter {
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {

        String ip = RpcContext.getContext().getUrl().getHost();
        if(StringUtils.isNotBlank(ip)){
            log.info("当前ip地址:{}",ip);
        }
        return invoker.invoke(invocation);
    }
}
